package com.linhngua.code.data.shop;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import com.linhngua.code.data.LimitedSizeList;

@Entity
public class Item implements Serializable {
	
	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;
	
	private int					id;
	
	private String				name;
	
	private Collection<String>	imageUrls;
	
	private String				description;
	
	private double				price;
	
	private String				currency;
	
	private Date				addedDate;
	
	private int					viewCount;
	
	private int					likeCount;
	
	private int					dislikeCount;
	
	private boolean				onSale;
	
	private double				discount;
	
	//belong to
	private Shop				shop;
	
	public Item() {

		this.imageUrls = new LimitedSizeList<String>(3);
	}
	
	public Item(String name, String description, double price, String currency,
			Date addedDate, int viewCount, int likeCount, int dislikeCount,
			boolean onSale, double discount) {

		super();
		this.name = name;
		this.imageUrls = new LimitedSizeList<String>(3);
		this.description = description;
		this.price = price;
		this.currency = currency;
		this.addedDate = addedDate;
		this.viewCount = viewCount;
		this.likeCount = likeCount;
		this.dislikeCount = dislikeCount;
		this.onSale = onSale;
		this.discount = discount;
	}
	
	public String getName() {

		return name;
	}
	
	public void setName(String name) {

		this.name = name;
	}
	
	@ElementCollection
	public Collection<String> getImageUrls() {

		return imageUrls;
	}
	
	public void addImageUrls(String... urls) {

		for (String url : urls) {
			imageUrls.add(url);
		}
	}
	
	public String getDescription() {

		return description;
	}
	
	public void setDescription(String description) {

		this.description = description;
	}
	
	public double getPrice() {

		return price;
	}
	
	public void setPrice(double price) {

		this.price = price;
	}
	
	public String getCurrency() {

		return currency;
	}
	
	public void setCurrency(String currency) {

		this.currency = currency;
	}
	
	public Date getAddedDate() {

		return addedDate;
	}
	
	public void setAddedDate(Date addedDate) {

		this.addedDate = addedDate;
	}
	
	public int getViewCount() {

		return viewCount;
	}
	
	public void setViewCount(int viewCount) {

		this.viewCount = viewCount;
	}
	
	public int getLikeCount() {

		return likeCount;
	}
	
	public void setLikeCount(int likeCount) {

		this.likeCount = likeCount;
	}
	
	public int getDislikeCount() {

		return dislikeCount;
	}
	
	public void setDislikeCount(int dislikeCount) {

		this.dislikeCount = dislikeCount;
	}
	
	public boolean isOnSale() {

		return onSale;
	}
	
	public void setOnSale(boolean onSale) {

		this.onSale = onSale;
	}
	
	public double getDiscount() {

		return discount;
	}
	
	public void setDiscount(double discount) {

		this.discount = discount;
	}
	
	@Id
	@GeneratedValue
	public int getId() {

		return id;
	}
	
	public void setId(int id) {

		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="Shop_id",nullable=false)
	public Shop getShop() {
	
		return shop;
	}

	
	public void setShop(Shop shop) {
	
		this.shop = shop;
	}

	
	public void setImageUrls(Collection<String> imageUrls) {
	
		this.imageUrls = imageUrls;
	}
	
}
